/** 充值总的页面逻辑 */
(function() {
    // 填充时间
    var now = new Date(), hour = now.getHours()
    if (hour < 6) {
        $("span.welcome").html("凌晨好")
    } else if (hour < 9) {
        $("span.welcome").html("早上好")
    } else if (hour < 12) {
        $("span.welcome").html("上午好")
    } else if (hour < 14) {
        $("span.welcome").html("中午好")
    } else if (hour < 17) {
        $("span.welcome").html("下午好")
    } else if (hour < 19) {
        $("span.welcome").html("傍晚好")
    } else if (hour < 22) {
        $("span.welcome").html("晚上好")
    } else {
        $("span.welcome").html("夜里好")
    }

    // 填充用户信息
    var fillUserInfo = function() {
        $("#userName").html(context.user.user.mobile);
        $("#balance").html((context.user.balance/100).toFixed(3));
        $("#loginTime").html(new Date(context.user.user.login).Format("yyyy-MM-dd HH:mm:ss"));
    }
    fillUserInfo();
    $(".balance .refresh5").click(function() {
        ME.query(fillUserInfo);
    });

    // 4个菜单的处理
    var menu = context.center.menu || 'charge_log';
    var drawMenus = function() {
        $(".membersubnavi .subnavi").removeClass("blue");
        $(".membersubnavi .subnavi[value='" + menu + "']").addClass("blue");
        $(".membersubnavi .subnavi .subnaviarrow").hide();
        $(".membersubnavi .blue .subnaviarrow").show();

        switch_page("center/money/" + menu, $("#subpage"));
    }
    drawMenus();
    $(".membersubnavi .subnavi").click(function(e) {
        menu = $(e.currentTarget).attr("value");
        drawMenus();
    });
})();
